package com.scope.customViews;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.widget.FrameLayout;
import android.widget.ImageView;

/**
 * Created by Samrith on 11/3/13.
 */

public class DualImageView extends FrameLayout implements CustomView.DualView<ImageView> {
    public DualImageView(Context context) {
        super(context);
        mContext = context;
        initializeViews();
    }

    Context mContext;
    ImageView mFront;
    ImageView mBack;

    public void toggle() {
        mBack.setVisibility(VISIBLE);
        mFront.setVisibility(GONE);
        ImageView temp = mFront;
        mFront = mBack;
        mBack = temp;
    }

    @Override
    public ImageView getFront() {
        return mFront;
    }

    @Override
    public ImageView getBack() {
        return mBack;
    }

    public void initializeViews() {
        CustomView.FreqLog.InitializingViews(this);
        mFront = new ImageView(mContext);
        mFront.setVisibility(VISIBLE);
        mBack = new ImageView(mContext);
        mBack.setVisibility(GONE);
        addView(mFront, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        addView(mBack, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        CustomView.FreqLog.PositionedViews(this);
    }

    public void setImageDrawable(Drawable drawable) {
        mBack.setImageDrawable(drawable);
    }

    public void setScaleType(ImageView.ScaleType type) {
        mFront.setScaleType(type);
        mBack.setScaleType(type);
    }
}